﻿@model  MinistryStandardPlatformWeb.Models.LoginModel

@{
    Layout = "~/Views/Shared/_CommonLayout.cshtml";
}


<link href="@Url.Content("~/Content/Login.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jQuery.encoding.digests.sha1.js")" type="text/javascript"></script>
<script  type="text/javascript" >
    $(document).ready(function () {
        if ($("#logincontainer").parent("div").length == 0) {
            $("#logincontainer").height($("#logincontainer").parent().height());
        }
        else {
            $("#logincontainer").addClass("fillparentheight");
        }

			$("#VerificationCodeImg").bind("click", function () {
				this.src = "/Login/VerificationCode/" + (new Date()).getTime();
			});

			//			$("#body").delegate(VerificationCodeImg,"click", function () {
			//				this.src = "VerificationCode?time=" + (new Date()).getTime();
			//			});

			$("#loginBtn").click(function () {
			    if ($("#UserId").val() == "") {
			        artDialogAlert('请填写用户名');
					return false;
				}

			    if ($("#PasswordTxt").val() == "") {
			        artDialogAlert('请填写密码');
					return false;
				}

			    if ($("#VerificationCode").val() == "") {
			        artDialogAlert('请填写验证码');
					return false;
				}

				var code;
				$.ajax({
					async: false,
					type: "POST",
					url: "/Login/GetVerificationCode?random=" + Math.random(),
					data: "{}",
					dataType: "",
					success: function (data) {
						code = data;
					},
					error: function (result) {
						code = "notfound";
					}


				});

				if ($("#VerificationCode").val().toUpperCase() != code.toUpperCase()) {
				    artDialogAlert('验证码错误');
					return false;
				}
				else {
				    $("#Password").val(encrypt($("#PasswordTxt").val()));
				}

				$("#PasswordTxt").val("");
			})
		});

		function encrypt(str)
		{
		    //return str;
		    return $.encoding.digests.hexSha1Str(str);
		}
</script>

<style>
    /*body
    {
        background: url(../../Images/loginbkg.jpg);
        background-position:center;
        background-repeat:no-repeat;
        background-attachment:fixed;
        background-color:rgb(45,184,173);
    }*/

    .logindiv
    {
        background: url(../../Images/loginbkg.jpg);
        background-position:center;
        background-repeat:no-repeat;
        background-attachment:fixed;
        background-color:rgb(45,184,173);
        /*position: absolute;
        width: 940px;
        height: 545px;
        top: 50%;
        left: 50%;
        margin-top: -272px;
        margin-left: -470px;*/
        vertical-align: middle;
        /*background: url(../../Images/loginbg.jpg);*/
        overflow: hidden;
    }

    .logincontentdiv
    {
        position: absolute;
        top: 50%;
        left: 50%;
        margin-top: -70px;
        margin-left: -140px;
    }

    .logincontentline
    {
        height: 60px;
        line-height: 60px;
        margin-top: -10px;
    }

    .logincontentline span
    {
        height: 24px;
        text-align: justify;
        text-justify: inter-ideograph;
    }

    a
    {
        color: #0000ff;
        text-decoration: underline;
        cursor: pointer;
    }

    a:link, a:visited
    {
        color: #F6855E;
        text-decoration: none;
    }

    a:hover
    {
        color: #333333;
        text-decoration: none;
    }

    /* Styles for validation helpers */
    .field-validation-error
    {
        color: #ff0000;
    }

    .field-validation-valid
    {
        display: none;
    }

    .input-validation-error
    {
        border: 1px solid #ff0000;
        background-color: #ffeeee;
    }

    .validation-summary-errors
    {
        font-weight: bold;
        color: #ff0000;
    }

    .validation-summary-valid
    {
        display: none;
    }


    .validation-summary-errors ul li
    {
        list-style-type: none;
    }
</style>
	<div id="logincontainer">
    <div class="logindiv fillparentheight">
        <div class="logincontentdiv">
            <form action="/Login/Login" method="post">
            <table border="0" cellpadding="0" cellspacing="0" style="text-align: left; vertical-align: middle; border: 0px">
                <tr style="height: 40px; border: none; vertical-align: middle; margin-top: 5px">
                    <td style="width: 30px">
                        <img src="@Url.Content("~/Images/user.png")" alt="用户名"/></td>
                    <td style="width: 50px"><label for="UserId">用户名</label></td>
                    <td colspan="2">@Html.TextBoxFor(m=>m.UserId,new { @id = "UserId", @style = "width:100%" })</td>
                </tr>
                <tr style="height: 40px; border: none; vertical-align: middle; margin-top: 5px">
                    <td>
                        <img src="@Url.Content("~/Images/password.png")" alt="密码"/></td>
                    <td>
                        <label for="Password">密&nbsp;&nbsp;&nbsp;码</label></td>
                    <td colspan="2">
                        <input type="password" name="PasswordTxt" id="PasswordTxt"  style="width:100%;"/>
                        @Html.HiddenFor(m => m.Password, new { @id = "Password" })
                    </td>
                </tr>
                <tr style="height: 40px; border: none; vertical-align: middle; margin-top: 5px">
                    <td>
                        <img src="@Url.Content("~/Images/verificationcode.png")" alt="验证码"/></td>
                    <td><label for="VerificationCode">验证码</label></td>
                    <td>@Html.TextBoxFor(m=>m.VerificationCode,new { @id = "VerificationCode"})</td>
                    <td>
                        <img id="VerificationCodeImg" src="/Login/VerificationCode" alt="验证码" title="看不清？点击更换！" style="cursor: pointer;vertical-align:middle;" /></td>
                </tr>
                <tr style="height: 40px; border: none; vertical-align: middle; margin-top: 5px">
                    <td></td>
                    <td style="text-align: center;vertical-align:middle;">@Html.CheckBoxFor(m => m.RememberMe, new { @style = "vertical-align:middle" })</td>
                    <td style="text-align: left;"><label for="RemeberMe" >记住我一周？</label></td>
                    <td></td>
                </tr>
                <tr style="border: none; vertical-align: middle; margin-top: 5px;">
                    <td></td>
                    <td colspan='3' style="text-align: center">
                        <input type="image" id="loginBtn" src="@Url.Content("~/Images/loginbtn.png")" style="height:30px;"/></td>
                </tr>
                <tr style="border: none; vertical-align: middle; margin-top: 5px; text-align: center">
                    
                    <td colspan='4' style="text-align: center">
                        @Html.ValidationSummary(false)
                    </td>
                </tr>
            </table>
                @Html.HiddenFor(model => model._ReturnUrl)
                </form>
        </div>
    </div>
        </div>